home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / RoboticInvaders.dxr / 00011_Engine Scripts.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  7.4 KB  |  215 lines

  1. global playerShipSO, armorSO, pBulletSO, eBulletSO, enemySO, enemyData, fleetMovementData, playerData, pBulletData, eBulletData, armorData, playerlevel, totalScore, playerScore, activeBullets, playerintro
  2.  
  3. on runBugs
  4.   global targetLocationList, deathDelay, frameNumber, frameDelay, totalBugs, accuracyRating, lowestRank, swoopDelay, targetlocation, selectedCraft, homein
  5.   if frameDelay <= 0 then
  6.     frameDelay = 5
  7.     if frameNumber < 3 then
  8.       frameNumber = frameNumber + 1
  9.     else
  10.       frameNumber = 1
  11.     end if
  12.   else
  13.     frameDelay = frameDelay - 1
  14.   end if
  15.   case fleetMovementData[2] of
  16.     #left:
  17.       if fleetMovementData[1][1] < 0 then
  18.         fleetMovementData[2] = #right
  19.         fleetMovementData[1][2] = fleetMovementData[1][2] + 5
  20.       end if
  21.     #right:
  22.       if fleetMovementData[1][1] > 180 then
  23.         fleetMovementData[2] = #left
  24.         fleetMovementData[1][2] = fleetMovementData[1][2] + 5
  25.       end if
  26.   end case
  27.   case fleetMovementData[2] of
  28.     #left:
  29.       fleetMovementData[1][1] = fleetMovementData[1][1] - 2
  30.     #right:
  31.       fleetMovementData[1][1] = fleetMovementData[1][1] + 2
  32.   end case
  33.   validLocs = []
  34.   totalBugs = 0
  35.   lowestRank = 0
  36.   repeat with wBug = 1 to count(enemyData)
  37.     if enemyData[wBug][1] = 1 then
  38.       if findDistance(playerData[2], enemyData[wBug][5]) <= 15 then
  39.         addparticle(playerData[2], 0, 1)
  40.         playerData[1] = 0
  41.       end if
  42.       if homein = 1 then
  43.       else
  44.       end if
  45.       if enemyData[wBug][6] <> 0 then
  46.         targetDestination = targetLocationList
  47.         case enemyData[wBug][7] of
  48.           2:
  49.             targetDestination = targetDestination + point(-50, -15)
  50.           3:
  51.             targetDestination = targetDestination + point(50, -15)
  52.         end case
  53.       else
  54.         targetDestination = enemyData[wBug][4] + fleetMovementData[1]
  55.       end if
  56.       moveAim = findAngle(enemyData[wBug][5], targetDestination)
  57.       moveDist = findDistance(enemyData[wBug][5], targetDestination)
  58.       if moveDist > 8 then
  59.         moveDist = 8
  60.       end if
  61.       wSprite = wBug + enemySO - 1
  62.       locY = cos(moveAim * PI / 180) * -moveDist
  63.       locX = sin(moveAim * PI / 180) * moveDist
  64.       enemyData[wBug][5] = enemyData[wBug][5] + point(locX, locY)
  65.       repeat with wBullet = 1 to count(pBulletData)
  66.         if pBulletData[wBullet][1] = 1 then
  67.           if findDistance(enemyData[wBug][5], pBulletData[wBullet][2]) <= 20 then
  68.             accuracyRating[1] = accuracyRating[1] + 1
  69.             pBulletData[wBullet][1] = 0
  70.             enemyData[wBug][3] = enemyData[wBug][3] + 1
  71.             set the loc of sprite (pBulletSO + wBullet - 1) to point(-50, -50)
  72.           end if
  73.         end if
  74.       end repeat
  75.       if enemyData[wBug][3] >= 1 then
  76.         playerScore = playerScore + (enemyData[wBug][2] * 15)
  77.         member("Score display").text = string(totalScore + playerScore)
  78.         addparticle(enemyData[wBug][5], 0, 1)
  79.         enemyData[wBug][1] = 0
  80.         set the loc of sprite wSprite to point(-50, -50)
  81.         next repeat
  82.       end if
  83.       set the loc of sprite wSprite to enemyData[wBug][5]
  84.       if (enemyData[wBug][4] + fleetMovementData[1])[2] > lowestRank then
  85.         lowestRank = (enemyData[wBug][4] + fleetMovementData[1])[2]
  86.       end if
  87.       set the member of sprite wSprite to "Robot" & ["1", "2", "3", "4"][enemyData[wBug][2]] & ["a", "b", "c", "d"][frameNumber]
  88.       add(validLocs, enemyData[wBug][5])
  89.       totalBugs = totalBugs + 1
  90.     end if
  91.   end repeat
  92.   if (deathDelay = 40) and (playerintro = 0) then
  93.     fleetMovementData[3] = fleetMovementData[3] - 1
  94.     if count(validLocs) > 0 then
  95.       if fleetMovementData[3] < 0 then
  96.         fleetMovementData[3] = [20, 15, 10, 8, 6][playerlevel] + random(10)
  97.         shootLoc = validLocs[random(count(validLocs))]
  98.         addEBullet(shootLoc, 6, random(10) + 175)
  99.       end if
  100.     end if
  101.   else
  102.   end if
  103. end
  104.  
  105. on updateArmors
  106.   totalArmors = 4
  107.   repeat with wArmor = 1 to totalArmors
  108.     wSprite = armorSO + wArmor - 1
  109.     rBit = armorData[wArmor][1]
  110.     if rBit = 0 then
  111.       sprite(wSprite).visible = 0
  112.       next repeat
  113.     end if
  114.     set the member of sprite wSprite to "Armor " & string(rBit)
  115.   end repeat
  116. end
  117.  
  118. on addBullet spawnloc, spawnSpeed, spawnAim
  119.   validSlot = 0
  120.   repeat with wSlot = 1 to count(pBulletData)
  121.     if (validSlot = 0) and (pBulletData[wSlot][1] = 0) then
  122.       validSlot = wSlot
  123.     end if
  124.   end repeat
  125.   if validSlot <> 0 then
  126.     pBulletData[validSlot] = [1, spawnloc, spawnSpeed, spawnAim]
  127.   end if
  128. end
  129.  
  130. on addEBullet spawnloc, spawnSpeed, spawnAim
  131.   validSlot = 0
  132.   repeat with wSlot = 1 to count(eBulletData)
  133.     if (validSlot = 0) and (eBulletData[wSlot][1] = 0) then
  134.       validSlot = wSlot
  135.     end if
  136.   end repeat
  137.   if validSlot <> 0 then
  138.     eBulletData[validSlot] = [1, spawnloc, spawnSpeed, spawnAim]
  139.   end if
  140. end
  141.  
  142. on runPBullets
  143.   activeBullets = 0
  144.   repeat with wBullet = 1 to count(pBulletData)
  145.     if pBulletData[wBullet][1] = 1 then
  146.       wSprite = pBulletSO + wBullet - 1
  147.       bLoc = pBulletData[wBullet][2]
  148.       validArmor = 0
  149.       repeat with vBlock = 1 to count(armorData)
  150.         if (validArmor = 0) and inside(bLoc, armorData[vBlock][3]) and (armorData[vBlock][1] > 0) then
  151.           validArmor = vBlock
  152.         end if
  153.       end repeat
  154.       if (bLoc[1] < 0) or (bLoc[1] > 580) or (bLoc[2] < 0) or (bLoc[2] > 440) then
  155.         pBulletData[wBullet][1] = 0
  156.         set the loc of sprite wSprite to point(-50, -50)
  157.         next repeat
  158.       end if
  159.       if validArmor <> 0 then
  160.         addparticle(bLoc, 0, 2)
  161.         armorData[validArmor][1] = armorData[validArmor][1] - 1
  162.         pBulletData[wBullet][1] = 0
  163.         set the loc of sprite wSprite to point(-50, -50)
  164.         next repeat
  165.       end if
  166.       tASpeed = pBulletData[wBullet][3]
  167.       tAim = pBulletData[wBullet][4]
  168.       locY = cos(tAim * PI / 180) * -tASpeed
  169.       locX = sin(tAim * PI / 180) * tASpeed
  170.       pBulletData[wBullet][2] = pBulletData[wBullet][2] + point(locX, locY)
  171.       set the loc of sprite wSprite to pBulletData[wBullet][2]
  172.       activeBullets = activeBullets + 1
  173.     end if
  174.   end repeat
  175. end
  176.  
  177. on runEBullets
  178.   repeat with wBullet = 1 to count(eBulletData)
  179.     if eBulletData[wBullet][1] = 1 then
  180.       wSprite = eBulletSO + wBullet - 1
  181.       bLoc = eBulletData[wBullet][2]
  182.       validArmor = 0
  183.       repeat with vBlock = 1 to count(armorData)
  184.         if (validArmor = 0) and inside(bLoc, armorData[vBlock][3]) and (armorData[vBlock][1] > 0) then
  185.           validArmor = vBlock
  186.         end if
  187.       end repeat
  188.       if findDistance(playerData[2], eBulletData[wBullet][2]) <= 15 then
  189.         eBulletData[wBullet][1] = 0
  190.         addparticle(playerData[2], 0, 1)
  191.         set the loc of sprite wSprite to point(-50, -50)
  192.         playerData[1] = 0
  193.         next repeat
  194.       end if
  195.       if (bLoc[1] < 0) or (bLoc[1] > 580) or (bLoc[2] < 0) or (bLoc[2] > 440) then
  196.         eBulletData[wBullet][1] = 0
  197.         set the loc of sprite wSprite to point(-50, -50)
  198.         next repeat
  199.       end if
  200.       if validArmor <> 0 then
  201.         armorData[validArmor][1] = armorData[validArmor][1] - 1
  202.         eBulletData[wBullet][1] = 0
  203.         set the loc of sprite wSprite to point(-50, -50)
  204.         next repeat
  205.       end if
  206.       tASpeed = eBulletData[wBullet][3]
  207.       tAim = eBulletData[wBullet][4]
  208.       locY = cos(tAim * PI / 180) * -tASpeed
  209.       locX = sin(tAim * PI / 180) * tASpeed
  210.       eBulletData[wBullet][2] = eBulletData[wBullet][2] + point(locX, locY)
  211.       set the loc of sprite wSprite to eBulletData[wBullet][2]
  212.     end if
  213.   end repeat
  214. end
  215.